#include<iostream>
#include<fstream>
#include"bundle.h"
using namespace std;

int main(int argc, char* argv[])
{
  if(argc < 3)
  {
    cout << "格式错误" << endl;
    return -1;
  }
  string ifilename = argv[1];//压缩文件
  string ofilename = argv[2];//压缩后的格式

  ifstream ifs;
  ifs.open(ifilename, std::ios::binary);
  ifs.seekg(0, std::ios::end);
  size_t sz = ifs.tellg();
  ifs.seekg(0, std::ios::beg);
  string msg;
  msg.resize(sz);
  ifs.read(&msg[0], sz);

  string packed = bundle::pack(bundle::LZIP, msg);
  
  ofstream ofs;
  ofs.open(ofilename, std::ios::binary);
  ofs.write(&packed[0], packed.size());

  ifs.close();
  ofs.close();
  
  return 0;
}
